#include <avr/io.h>
#include "PinMap.h"

//#define floorADC1 1 //    PF1
//#define floorADC2 4 //    PB4
//#define floorADC3 7 //    PD7
//#define floorADC4 6 //    PD6
//#define floorADC5 4 //    PF4
//#define floorLEDs 7 //    PB7
//
void LineSensorsSetup()
{
  //input
  DDRB &= ~(1<<floorADC2);
  DDRD &= ~(1<<floorADC3|1<<floorADC4);
  DDRF &= ~(floorADC1|floorADC5);
  PORTB &= ~(1<<floorADC2);
  PORTD &= ~(1<<floorADC3|1<<floorADC4);
  PORTF &= ~(floorADC1|floorADC5);
  //output
  DDRB |= 1<<floorLEDs;
  PORTB &= ~(1<<floorLEDs);
  
}

void floorLEDsOn()
{
  PORTB |= 1<<floorLEDs;
}

void floorLEDsOff()
{
  PORTB &= ~(1<<floorLEDs);
}

void readLineSensors()
{
	//lineSensorData.sensor1 = (unsigned char)((analogRead(floorADC1) >> 2) & 0xFF);
	//lineSensorData.sensor2 = (unsigned char)((analogRead(floorADC2) >> 2) & 0xFF);
	//lineSensorData.sensor3 = (unsigned char)((analogRead(floorADC3) >> 2) & 0xFF);
	//lineSensorData.sensor4 = (unsigned char)((analogRead(floorADC4) >> 2) & 0xFF);
	//lineSensorData.sensor5 = (unsigned char)((analogRead(floorADC5) >> 2) & 0xFF);
  lineSensorData.dataFresh = true;
}


//#include <avr/io.h>
//#include <avr/interrupt.h>
//
//int main (void)
//{
  //DDRE |= (1 << 2); // Set LED1 as output
  //DDRG |= (1 << 0); // Set LED2 as output
//
  //ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Set ADC prescaler to 128 - 125KHz sample rate @ 16MHz
//
  //ADMUX |= (1 << REFS0); // Set ADC reference to AVCC
  //ADMUX |= (1 << ADLAR); // Left adjust ADC result to allow easy 8 bit reading
//
  //// No MUX values needed to be changed to use ADC0
//
  //ADCSRA |= (1 << ADFR);  // Set ADC to Free-Running Mode
  //ADCSRA |= (1 << ADEN);  // Enable ADC
//
  //ADCSRA |= (1 << ADIE);  // Enable ADC Interrupt
  //sei();   // Enable Global Interrupts
//
  //ADCSRA |= (1 << ADSC);  // Start A2D Conversions
//
  //for(;;)  // Loop Forever
  //{
  //}
//}
//
//ISR(ADC_vect)
//{
  //if(ADCH < 128)
  //{
    //PORTE |= (1 << 2); // Turn on LED1
    //PORTG &= ~(1 << 0); // Turn off LED2
  //}
  //
  //else
  //{
    //PORTE &= ~(1 << 2); // Turn off LED1
    //PORTG |= (1 << 0); // Turn on LED2
  //}
//}
//



